#include<iostream>
#include<algorithm>
using namespace std;
const int N = 60;
char s[N][N];
bool find(char c)
{
	for (int i = 0; i < 3; i++) {
		bool flag = 1;
		for (int j = 0; j < 3; j++) {
			if (s[i][j] != c)flag = 0;
		}
		if (flag)return 1;
	}
	for (int i = 0; i < 3; i++) {
		bool flag = 1;
		for (int j = 0; j < 3; j++) {
			if (s[j][i] != c)flag = 0;
		}
		if (flag)return 1;
	}
	if (s[0][0] == c && s[1][1] == c && s[2][2] == c)return 1;
	if (s[0][2] == c && s[1][1] == c && s[2][0] == c)return 1;
	return 0;
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				cin >> s[i][j];
			}
		}
		if (find('O'))cout << "O" << endl;
		else if (find('X'))cout << "X" << endl;
		else if (find('+'))cout << "+" << endl;
		else cout << "DRAW" << endl;
	}
	return 0;
}